package com.hongshan.wallet.core.home

import com.hongshan.wallet.BR
import com.hongshan.wallet.MyApplication
import com.hongshan.wallet.R
import com.hongshan.wallet.base.BasePagerAdapter
import com.hongshan.wallet.bean.BannerListBean

/**
 * Copyright Zhangxx.
 * Copyright (c) 2019
 * All rights reserved
 *
 * @project  : Wallet
 * @package  : com.example.wallet.core.home
 * @author   : zhangxx
 * @data     : 2019/3/21
 * @email    : qq957413212@hotmail.com
 */
class BannerPagerAdapter(var bannerList:BannerListBean?): BasePagerAdapter<HomePagerViewModel>(){

    override fun getLayoutId(position: Int) = R.layout.pager_item_banner

    override fun getBrId(position: Int) = BR.homePageVm

    override fun getViewModel(position: Int): HomePagerViewModel {
        val viewModel = HomePagerViewModel(MyApplication.applicationContext)
        viewModel.imgUrl.set(bannerList!!.items[position].img?.url)
        return viewModel
    }

    override fun getCount() = bannerList?.items?.size?:0
}